import requests


headers = {
    "accept": "*/*",
    "accept-language": "zh-CN,zh;q=0.9",
    "cache-control": "no-cache",
    "origin": "https://www.iqiyi.com",
    "pragma": "no-cache",
    "priority": "u=1, i",
    "referer": "https://www.iqiyi.com/",
    "sec-ch-ua": "\"Google Chrome\";v=\"131\", \"Chromium\";v=\"131\", \"Not_A Brand\";v=\"24\"",
    "sec-ch-ua-mobile": "?0",
    "sec-ch-ua-platform": "\"Windows\"",
    "sec-fetch-dest": "empty",
    "sec-fetch-mode": "cors",
    "sec-fetch-site": "same-site",
    "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"
}
url = "https://mesh.if.iqiyi.com/portal/lw/videolib/data"
count = 0
page = 0
while True:
    page += 1
    params = {
        "uid": "",
        "passport_id": "",
        "ret_num": "60",
        "version": "12.112.20682",
        "device_id": "f0f58dd33cc7c5a84b01d7bad789db53",
        "channel_id": "1",
        "page_id": page,
        "os": "",
        "conduit_id": "",
        "vip": "0",
        "auth": "",
        "recent_selected_tag": "",
        "ad": "[{\"lm\":\"5\",\"ai\":\"5\",\"fp\":\"6\",\"sei\":\"Sf1ff8f3d0f08f955d3b644463372a520\",\"position\":\"library\"}]",
        "adExt": "{\"r\":\"1.1.5-ares6-pure\"}",
        "dfp": "a08d166cb33ee042918b5fbe7c91831e4987afadd752994e4237bc61c777824d00",
        "filter": "{\"mode\":\"24\"}"
    }
    response = requests.get(url, headers=headers, params=params)
    count += 1
    if response.json()['has_next'] == 0:
        print(response.json())
        print(response,count)
        break
    print(response.json())
    print(response,count)